<template>
	<view class="fill-width-height">
		<uv-grid :col="colNum" class="fill-width" >
			<uv-grid-item 
				v-for="(url,index) in tableDataList" 
				:key="index"
				:customStyle="{padding: '6px'}"
			 >
				<uv-image 
					mode="widthFix" 
					radius="10" 
					width="100%" 
					:lazy-load="true"
					:fade="true"
					:duration="450"
					:showMenuByLongpress="false"
					:src="viewFile(url)"
					@click="goToEditPage(url)"
				>
					<template v-slot:loading>
						<uv-loading-icon color="red"></uv-loading-icon>
					</template>
				</uv-image>
			</uv-grid-item>
		</uv-grid>
	</view>
</template>

<script>
	import { getImgListByCode } from "@/api/home/index.js";
	export default {
		data() {
			return {
				tableDataList: []
			}
		},
		computed: {
			colNum(){
				return this.$config.searchViewImgColNum || 4
			}
		},
		methods: {
			async getDataList(){
				const dataList = await getImgListByCode({ code: 'wuzi' }).then(res => res.data )
				// dataList.forEach(item => {
				//   let imgUrl = 'imgStore/openApi/previewByBussId?bussid=' + item.id + "&size=original";
				//   item.url = this.$config.replacehUrl(imgUrl)
				// })
				this.tableDataList = dataList
			},
			viewFile(url){
				if(url?.startsWith('http') > 0){
					return url
				}
				return this.$getPreviewPath(url)
			},
			goToEditPage(iurl){
				let imgUrl = encodeURIComponent(iurl)
				const url = `/pages/customwordlessImg/mem/index?imgUrl=${imgUrl}`
				uni.navigateTo({
				  url: url 
				});
			}
		},
		mounted(){
			this.getDataList()
		}
	}
</script>

<style>

</style>
